home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / External Tool Templates / CPlus Tool Template / ScriptValue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-04  |  5.6 KB  |  205 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    File:        ScriptValue.h
  3.  *
  4.  *    Contains:    xxx put contents here xxx
  5.  *
  6.  *    Written by:    Rick Violet
  7.  *
  8.  *    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9.  *
  10.  *    Change History (most recent first):
  11.  *
  12.  *        <1+>     5/18/93    RV        Added literal values for ValueKind enum
  13.  *                11/18/92    RV        xxx put comment here xxx
  14.  *
  15.  *    To Do:
  16.  */
  17.  
  18. #ifndef __ScriptValue__
  19. #define __ScriptValue__
  20.  
  21. #ifndef __TYPES__
  22. #include     <Types.h>
  23. #endif
  24.  
  25. #ifndef __APPLEEVENTS__
  26. #include     <AppleEvents.h>
  27. #endif
  28.  
  29. #ifndef    __STRING__
  30. #include    <String.h>
  31. #endif
  32.  
  33. #ifndef __VUAE__
  34. #include     "VUAE.h"
  35. #endif
  36.  
  37. #ifndef __Object__
  38. #include     "Object.h"
  39. #endif
  40.  
  41. enum    ValueKind
  42.         {
  43.             kVUAnyKind             = -2,
  44.             kVUNullKind         = -1,
  45.             kVUBooleanKind         =  0,
  46.             kVUNumberKind         =  1,
  47.             kVULongNumberKind    =  2,
  48.             kVUStringKind         =  3,
  49.             kVUListKind         =  4
  50.         };
  51.  
  52. class ScriptValue;
  53.  
  54. typedef ScriptValue* ScriptValuePtr;
  55.  
  56. //—————————————————————————————————————————————————————————————————————————————————————
  57. //    ScriptValue class -    abstract class for values passed to and from V.U. scripts
  58. //—————————————————————————————————————————————————————————————————————————————————————
  59. class ScriptValue : public Object
  60. {
  61.     ScriptValue*    fNextValue;
  62.     
  63. protected:    //———————————————————————    protected member variables
  64.     ValueKind    fValueKind;
  65.     
  66. public:        //———————————————————————    public member functions
  67.  
  68.                     ScriptValue();                        
  69. virtual                ~ScriptValue(){};
  70.                     
  71.         ValueKind        GetValueKind(){ return fValueKind; };
  72.         ScriptValue*    GetNextValue(){ return fNextValue; };
  73.         void            SetNextValue( ScriptValue* pValue ){ fNextValue = pValue; };
  74. virtual    ScriptValue*    Clone();
  75. };
  76.  
  77. //—————————————————————————————————————————————————————————————————————————————————————
  78. //    VUNull class -    for undefined values passed to and from V.U. scripts
  79. //—————————————————————————————————————————————————————————————————————————————————————
  80. class VUNull: public ScriptValue
  81. {
  82. public:        //———————————————————————    public member functions
  83.  
  84.                         VUNull();                        
  85. virtual                    ~VUNull(){};
  86. virtual    ScriptValue*    Clone();
  87. };
  88.  
  89. //—————————————————————————————————————————————————————————————————————————————————————
  90. //    VUBoolean class -    for boolean values passed to and from V.U. scripts
  91. //—————————————————————————————————————————————————————————————————————————————————————
  92. class VUBoolean: public ScriptValue
  93. {
  94.     Boolean    fFlag;
  95.     
  96. public:        //———————————————————————    public member functions
  97.  
  98.                     VUBoolean( Boolean    pFlag );                        
  99. virtual                ~VUBoolean(){};
  100.         Boolean        GetBoolean();
  101. virtual    ScriptValue*    Clone();
  102. };
  103.  
  104. //—————————————————————————————————————————————————————————————————————————————————————
  105. //    VUNumber class -    for number values passed to and from V.U. scripts
  106. //—————————————————————————————————————————————————————————————————————————————————————
  107. class VUNumber: public ScriptValue
  108. {
  109.     short    fNumber;
  110.     
  111. public:        //———————————————————————    public member functions
  112.  
  113.                     VUNumber( short    pNumber );                        
  114. virtual                ~VUNumber(){};
  115.         short        GetNumber();
  116. virtual    ScriptValue*    Clone();
  117. };
  118.  
  119. //—————————————————————————————————————————————————————————————————————————————————————
  120. //    VULongNumber class -    for return id of apple events, which identify Requests
  121. //                        to be canceled.
  122. //—————————————————————————————————————————————————————————————————————————————————————
  123. class VULongNumber: public ScriptValue
  124. {
  125.     long    fNumber;
  126.     
  127. public:        //———————————————————————    public member functions
  128.  
  129.                         VULongNumber( long    pNumber );                        
  130. virtual                    ~VULongNumber(){};
  131.         long            GetNumber();
  132. virtual    ScriptValue*    Clone();
  133. };
  134.  
  135. //—————————————————————————————————————————————————————————————————————————————————————
  136. //    VUNumber class -    for string values passed to and from V.U. scripts
  137. //—————————————————————————————————————————————————————————————————————————————————————
  138. class VUString: public ScriptValue
  139. {
  140.     char*    fText;
  141.     
  142. public:        //———————————————————————    public member functions
  143.  
  144.                     VUString( char* pText );                        
  145. virtual                ~VUString();
  146.                     
  147.                     //————    Returns a pointer to the Text
  148.         char*        GetText();
  149. unsigned    
  150.         short        GetTextSize();
  151.                     
  152. virtual    ScriptValue*    Clone();
  153. };
  154.  
  155. //—————————————————————————————————————————————————————————————————————————————————————
  156. //    VUList class -    for list values passed to and from V.U. scripts
  157. //—————————————————————————————————————————————————————————————————————————————————————
  158. class VUList: public ScriptValue
  159. {
  160.     short            fCount;
  161.     ScriptValue*    fListHead;
  162.     
  163. public:        //———————————————————————    public member functions
  164.  
  165.                     //————    Constructor - creating for reply
  166.                     VUList();                        
  167.  
  168.                     //————    Destructor
  169. virtual                ~VUList();
  170.                     
  171.                     //————    Get the number of items in the list
  172.         short        GetCount();
  173.  
  174. private:    //———————————————————————    private member functions
  175.  
  176.                     //————    Get the indexed item from the list
  177.                     //————    returns nil in case of error
  178.     ScriptValue*    GetNthItem( short pIndex );
  179.  
  180. public:        //———————————————————————    public member functions
  181.  
  182.                     //————    Get the indexed item from the list 
  183.         OSErr        GetNthItem( short pIndex, ScriptValuePtr& pItemPtr, ValueKind& pKind );
  184.  
  185.                     //————    Insert a ScriptValue into the list at the indexed position
  186.         void        PutNthItem( ScriptValue* pValue, short pIndex = 32767 );
  187.                     
  188.                     //————    Insert a Boolean into the list at the indexed position
  189.         void        PutNthItem( Boolean pFlag, short pIndex = 32767 );
  190.                     
  191.                     //————    Insert a Number into the list at the indexed position
  192.         void        PutNthItem( short pNumber, short pIndex = 32767 );
  193.                     
  194.                     //————    Insert a ScriptValue into the list at the indexed position
  195.         void        PutNthItem( char* pString, short pIndex = 32767 );
  196.                     
  197.                     //————    Insert a long Number into the list at the indexed position
  198.         void        PutNthItem( long pNumber, short pIndex = 32767 );
  199.                     
  200. virtual    ScriptValue*    Clone();
  201. };
  202.  
  203.  
  204. #endif
  205.